/*
 * Generated by XDoclet - Do not edit!
 */
package hotel.interfaces;

/**
 * Value object for Client.
 *
 * @xdoclet-generated at ${TODAY}
 * @copyright The XDoclet Team
 * @author XDoclet
 * @version ${version}
 */
public class ClientValue
   extends java.lang.Object
   implements java.io.Serializable 
{
   private java.lang.Integer DNI;
   private boolean DNIHasBeenSet = false;
   private java.lang.String nom;
   private boolean nomHasBeenSet = false;

   private hotel.interfaces.ClientPK pk;

   public ClientValue()
   {
	  pk = new hotel.interfaces.ClientPK();
   }

   public ClientValue( java.lang.Integer DNI,java.lang.String nom )
   {
	  this.DNI = DNI;
	  DNIHasBeenSet = true;
	  this.nom = nom;
	  nomHasBeenSet = true;
	  pk = new hotel.interfaces.ClientPK(this.getDNI());
   }

   //TODO Cloneable is better than this !
   public ClientValue( ClientValue otherValue )
   {
	  this.DNI = otherValue.DNI;
	  DNIHasBeenSet = true;
	  this.nom = otherValue.nom;
	  nomHasBeenSet = true;

	  pk = new hotel.interfaces.ClientPK(this.getDNI());
   }

   public hotel.interfaces.ClientPK getPrimaryKey()
   {
	  return pk;
   }

   public void setPrimaryKey( hotel.interfaces.ClientPK pk )
   {
      // it's also nice to update PK object - just in case
      // somebody would ask for it later...
      this.pk = pk;
	  setDNI( pk.DNI );
   }

   public java.lang.Integer getDNI()
   {
	  return this.DNI;
   }

   public void setDNI( java.lang.Integer DNI )
   {
	  this.DNI = DNI;
	  DNIHasBeenSet = true;

		 pk.setDNI(DNI);
   }

   public boolean DNIHasBeenSet(){
	  return DNIHasBeenSet;
   }
   public java.lang.String getNom()
   {
	  return this.nom;
   }

   public void setNom( java.lang.String nom )
   {
	  this.nom = nom;
	  nomHasBeenSet = true;

   }

   public boolean nomHasBeenSet(){
	  return nomHasBeenSet;
   }

   public String toString()
   {
	  StringBuffer str = new StringBuffer("{");

	  str.append("DNI=" + getDNI() + " " + "nom=" + getNom());
	  str.append('}');

	  return(str.toString());
   }

   /**
    * A Value Object has an identity if the attributes making its Primary Key have all been set. An object without identity is never equal to any other object.
    *
    * @return true if this instance has an identity.
    */
   protected boolean hasIdentity()
   {
	  boolean ret = true;
	  ret = ret && DNIHasBeenSet;
	  return ret;
   }

   public boolean equals(Object other)
   {
      if (this == other)
         return true;
	  if ( ! hasIdentity() ) return false;
	  if (other instanceof ClientValue)
	  {
		 ClientValue that = (ClientValue) other;
		 if ( ! that.hasIdentity() ) return false;
		 boolean lEquals = true;
		 if( this.DNI == null )
		 {
			lEquals = lEquals && ( that.DNI == null );
		 }
		 else
		 {
			lEquals = lEquals && this.DNI.equals( that.DNI );
		 }

		 lEquals = lEquals && isIdentical(that);

		 return lEquals;
	  }
	  else
	  {
		 return false;
	  }
   }

   public boolean isIdentical(Object other)
   {
	  if (other instanceof ClientValue)
	  {
		 ClientValue that = (ClientValue) other;
		 boolean lEquals = true;
		 if( this.nom == null )
		 {
			lEquals = lEquals && ( that.nom == null );
		 }
		 else
		 {
			lEquals = lEquals && this.nom.equals( that.nom );
		 }

		 return lEquals;
	  }
	  else
	  {
		 return false;
	  }
   }

   public int hashCode(){
	  int result = 17;
      result = 37*result + ((this.DNI != null) ? this.DNI.hashCode() : 0);

      result = 37*result + ((this.nom != null) ? this.nom.hashCode() : 0);

	  return result;
   }

}
